def jiecheng(x):
    ans = 1
    for i in range(1, x + 1):
        ans *= i
    return ans

n = int(input())
a = list(map(int, input().split()))
sum_a = 0
for i in a:
    sum_a += jiecheng(i) 
m = 1
while jiecheng(m) <= sum_a:
    m += 1

print(m-1)
